﻿using System;
using System.Web.UI;


namespace BSPortal
{
    public partial class Admin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string page = Request.QueryString["Page"];

            if(System.Web.HttpContext.Current.Session["UserType"] == null || (int)System.Web.HttpContext.Current.Session["UserType"] != (int) Common.UserType.ADMIN)
                Response.Redirect("Default.aspx?Page=Login");

            GetContentPage(page);
            if(!IsPostBack)
            {
            }
        }

        private void GetContentPage(string typePage)
        {
            Control ctrContent = new Control();
            switch (typePage)
            {
                case "list":
                    ctrContent = Page.LoadControl("~/Usercontrol/Admin/Book/ListBook/ListBook.ascx");
                    break;
                case "category":
                    ctrContent = Page.LoadControl("~/Usercontrol/Admin/Book/Categorys/Category.ascx");
                    break;
                case "writer":
                    ctrContent = Page.LoadControl("~/Usercontrol/Admin/Book/Writer/ListWriter.ascx");
                    break;
                case "publisher":
                    ctrContent = Page.LoadControl("~/Usercontrol/Admin/Book/Publisher/ListPublisher.ascx");
                    break;
                case "Order":
                    ctrContent = Page.LoadControl("~/Usercontrol/Admin/Book/Order/ListOrder.ascx");
                    break;
                case "HTMLContent":
                    ctrContent = Page.LoadControl("~/Usercontrol/Admin/Book/HTML/ListHTMLContent.ascx");
                    break;
                case "User":
                    ctrContent = Page.LoadControl("~/Usercontrol/Admin/Book/User/ListUser.ascx");
                    break;
                case "location":
                    var line = Request.QueryString["Line"];
                    if(line == "1")
                        ctrContent = Page.LoadControl("~/Usercontrol/Admin/Book/Location/frmListCity.ascx");
                    else if( line == "2")
                        ctrContent = Page.LoadControl("~/Usercontrol/Admin/Book/Location/frmListDistrict.ascx");
                    else
                        ctrContent = Page.LoadControl("~/Usercontrol/Admin/Book/Location/frmListWard.ascx");
                    break;
                default:
                    ctrContent = Page.LoadControl("~/Usercontrol/Admin/Book/ListBook/ListBook.ascx");
                    break;
            }
            //UCMenu1.CurrentMenu = typePage;
            //UCMenuRM1.CurrentMenu = typePage;
            plContent.Controls.Add(ctrContent);
        }
    }
}
